"""生成项目依赖文件"""

import subprocess


def create_requirements():
    """创建requirements.txt文件"""
    requirements = [
        "pandas",  # 数据处理
        "openpyxl",  # Excel文件支持
        "PyMySQL",  # MySQL数据库支持
        "oracledb",  # Oracle数据库支持
    ]

    # 写入requirements.txt
    with open("requirements.txt", "w", encoding="utf-8") as f:
        for req in requirements:
            f.write(f"{req}\n")

    print("已创建requirements.txt文件")


def install_requirements():
    """安装依赖"""
    try:
        subprocess.run(["pip", "install", "-r", "requirements.txt"], check=True)
        print("依赖安装完成")
    except subprocess.CalledProcessError as e:
        print(f"依赖安装失败: {e}")


if __name__ == "__main__":
    create_requirements()
    install_requirements()
